home *** CD-ROM | disk | FTP | other *** search
/ SPACE 2 / SPACE - Library 2 - Volume 1.iso / program / 317 / asmsrc / output-f.c < prev    next >
Encoding:
C/C++ Source or Header  |  1988-10-20  |  2.1 KB  |  82 lines

  1. /* output-file.c - */
  2.  
  3. /* Copyright (C) 1987 Free Software Foundation, Inc.
  4.  
  5. This file is part of Gas, the GNU Assembler.
  6.  
  7. The GNU assembler is distributed in the hope that it will be
  8. useful, but WITHOUT ANY WARRANTY.  No author or distributor
  9. accepts responsibility to anyone for the consequences of using it
  10. or for whether it serves any particular purpose or works at all,
  11. unless he says so in writing.  Refer to the GNU Assembler General
  12. Public License for full details.
  13.  
  14. Everyone is granted permission to copy, modify and redistribute
  15. the GNU Assembler, but only under the conditions described in the
  16. GNU Assembler General Public License.  A copy of this license is
  17. supposed to have been given to you along with the GNU Assembler
  18. so you can know your rights and responsibilities.  It should be
  19. in a file named COPYING.  Among other things, the copyright
  20. notice and this notice must be preserved on all copies.  */
  21.  
  22. /*
  23.  * Confines all details of emitting object bytes to this module.
  24.  * All O/S specific crocks should live here.
  25.  * What we lose in "efficiency" we gain in modularity.
  26.  * Note we don't need to #include the "as.h" file. No common coupling!
  27.  */
  28.  
  29. /* #include "style.h" */
  30. #include <stdio.h>
  31.  
  32. void    as_perror();
  33.  
  34. static FILE *
  35. stdoutput;
  36.  
  37. void
  38. output_file_create (name)
  39.      char *        name;
  40. {
  41.   if ( ! (stdoutput = fopen( name, "w" )) )
  42.     {
  43.       as_perror ("Can't create object file", name);
  44.       as_fatal("Can't continue");
  45.     }
  46. }
  47.  
  48.  
  49.  
  50. void
  51. output_file_close (filename)
  52.      char *    filename;
  53. {
  54.   if ( EOF == fclose( stdoutput ) )
  55.     {
  56.       as_perror ("Can't close object file", filename);
  57.       as_fatal("Can't continue");
  58.     }
  59.   stdoutput = NULL;        /* Trust nobody! */
  60. }
  61.  
  62. void
  63. output_file_append (where, length, filename)
  64.      char *        where;
  65.      long int        length;
  66.      char *        filename;
  67. {
  68.  
  69.   for (; length; length--,where++)
  70.     {
  71.         (void)putc(*where,stdoutput);
  72.     if(ferror(stdoutput))
  73.       /* if ( EOF == (putc( *where, stdoutput )) ) */
  74.     {
  75.       as_perror("Failed to emit an object byte", filename);
  76.       as_fatal("Can't continue");
  77.     }
  78.     }
  79. }
  80.  
  81. /* end: output-file.c */
  82.